<template>
  <!-- 设置 -->
  <div class="setting">
    <div class="top">
      <img src="@/assets/img/icons/black/back.svg" class="back" @click="$router.back()" />
      <div class="title">设置</div>
      <div class="placeorder"></div>
    </div>
    <div class="line"></div>
    <k-scroll
      class="scroll"
      topColor="var(--main-background-color)"
      bottomColor="var(--main-background-color)"
      topType="stretch"
      bottomType="stretch"
    >
      <div class="content">
        <div class="item" @click="changePassword">
          <div class="title-item">修改密码</div>
          <img class="enter" src="@/assets/img/icons/enter.svg" />
        </div>
        <div class="item" @click="$router.push('/agreement')">
          <div class="title-item">用户协议</div>
          <img class="enter" src="@/assets/img/icons/enter.svg" />
        </div>
        <div class="item" @click="$router.push('/privacy')">
          <div class="title-item">隐私政策</div>
          <img class="enter" src="@/assets/img/icons/enter.svg" />
        </div>
        <div class="item" @click="checkUpdate">
          <div class="title-item">检查更新</div>
          <div class="value">版本号v1.0</div>
          <img class="enter" src="@/assets/img/icons/enter.svg" />
        </div>
      </div>
    </k-scroll>
  </div>
</template>

<script>
export default {
  name: 'setting',
  data() {
    return {}
  },
  methods: {
    //修改密码
    changePassword() {
      //进入设置密码或修改密码
      if (this.$store.state.userInfo.password) {
        this.$router.push({
          path: '/changePassword',
        })
      } else {
        if (this.$store.getters.getToken) {
          this.$network
            .main('postNull', 'preCheckToken')
            .then((data) => {
              this.$router.push({
                path: '/setPassword',
              })
            })
            .catch((err) => {
              //网络出错
              this.$dialog({
                title: 'Error',
                message: 'msg：' + err,
              })
            })
        } else {
          this.$dialog({
            message: '您还未登录！',
          })
        }
      }
    },
    //检查更新
    checkUpdate() {},
  },
}
</script>

<style scoped src="./index.css"></style>
